<?php

/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Badge
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */

class Badge_Form_Filter_Badge extends Engine_Form {
	
	public function init() {
		
		$this->clearDecorators ()->addDecorators ( array ('FormElements', array ('HtmlTag', array ('tag' => 'dl' ) ), 'Form' ) );
		
		$this->setAttrib ( 'class', 'filters' );
		$this->setAction ( Zend_Controller_Front::getInstance ()->getRouter ()->assemble ( array ('action' => 'browse' ), 'badge_general', true ) );
		
		// Add custom elements
		$this->getAdditionalOptionsElement ();
	
	}
	
	public function getAdditionalOptionsElement() {
		$i = - 5000;
		
		$this->addElement ( 'Hidden', 'page', array ()//  'order' => $i++,
		 );
		
		$this->addElement ( 'Text', 'keyword', array ('label' => 'Keywords:', //  'order' => $i++,
		'decorators' => array ('ViewHelper', array ('HtmlTag', array ('tag' => 'dd' ) ), array ('Label', array ('tag' => 'dt', 'placement' => 'PREPEND' ) ) )

		 ) );
		
		$categories = Engine_Api::_ ()->badge ()->getCategories ();
		
		$categories_prepared = Engine_Api::_ ()->badge ()->convertCategoriesToArray ( $categories );
		$categories_prepared = array ("" => "" ) + $categories_prepared;
		
		// category field
		$this->addElement ( 'Select', 'category', array ('label' => 'Category:', //  'order' => $i++,
		'multiOptions' => $categories_prepared, 'filters' => array (new Radcodes_Lib_Filter_Null () ), 'decorators' => array ('ViewHelper', array ('HtmlTag', array ('tag' => 'dd' ) ), array ('Label', array ('tag' => 'dt', 'placement' => 'PREPEND' ) ) ) ) );
		
		$this->addElement ( 'Select', 'membership_type', array ('label' => 'Assignment Type:', 'multiOptions' => array ("" => "" ) + array (Badge_Model_Badge::MEMBERSHIP_TYPE_AWARD => 'Award (Manual)', Badge_Model_Badge::MEMBERSHIP_TYPE_MAPPING => 'Mapping (Automatic)' ), // 'order' => $i++,
		'decorators' => array ('ViewHelper', array ('HtmlTag', array ('tag' => 'dd' ) ), array ('Label', array ('tag' => 'dt', 'placement' => 'PREPEND' ) ) ), 'filters' => array (new Radcodes_Lib_Filter_Null () ) ) );
		
		$this->addElement ( 'Select', 'order', array ('label' => 'List By:', //  'order' => $i++,
		'multiOptions' => array ('alphabet' => 'Title', 'recent' => 'Recently Created' ), 'filters' => array (new Radcodes_Lib_Filter_Null () ), 'decorators' => array ('ViewHelper', array ('HtmlTag', array ('tag' => 'dd' ) ), array ('Label', array ('tag' => 'dt', 'placement' => 'PREPEND' ) ) ) ) );
		
		$j = 10000000;
		
		$this->addElement ( 'Button', 'done', array ('label' => 'Search', 'type' => 'submit', 'ignore' => true, //'order' => $j++,
		'decorators' => array ('ViewHelper', array ('HtmlTag', array ('tag' => 'dd' ) ) ) ) );
	}
}